<?php
//指定表($table),制定条件($condition1/conditon2)的指定字段($f)
function getdataf($f,$table,$condition1,$condition2){
	mysql_query('set names utf8');
	$query="select ".$f." from ".$table." where ".$condition1."='".$condition2."'";
	$result=mysql_query($query) or die(mysql_errno());
	$row=mysql_fetch_array($result);

	return $row[$f];
}

//获取指定条件的全部信息
function getdataall($table,$condition1,$condition2){
	mysql_query('set names utf8');
	$query="select * from ".$table." where ".$condition1." ='".$condition2."'";
	$result=mysql_query($query) or die(mysql_error());
	$row=mysql_fetch_array($result);


	return $row;
}

//获取指定表的指定字段的所有信息
function getdataallf($f,$table){
	mysql_query('set names utf8');
	$resultrow="";
	$query="select ".$f." from ".$table;
	$result=mysql_query($query) or die(mysql_error());
	$i=0;
	while ($row=mysql_fetch_array($result)) {
		$resultrow[$i]=$row[$f];
		$i++;
	}

	return $resultrow;
}
//获取指定表的指定字段的有条件的所有信息
function getdataallfc($f,$table,$condition1,$condition2){
	mysql_query('set names utf8');
	$resultrow="";
	$query="select ".$f." from ".$table." where ".$condition1." = '".$condition2."'";
	$result=mysql_query($query) or die(mysql_error());
	$i=0;
	while ($row=mysql_fetch_array($result)) {
		$resultrow[$i]=$row[$f];
		$i++;
	}

	return $resultrow;
}

function getdatafcc($f,$table,$condition1,$condition2,$condition3,$condition4){
	mysql_query('set names utf8');
	$resultrow="";
	$query="select ".$f." from ".$table." where ".$condition1." = '".$condition2."' and ".$condition3." ='".$condition4."';";
	$result=mysql_query($query) or die(mysql_error());
	$row=mysql_fetch_array($result);


	return $row;
}

//修改属性
function updatef($table,$value,$condition1,$condition2){

	mysql_query('set names utf8');
	$query="update ".$table." set ".$value." where ".$condition1."='".$condition2."';";
	
	mysql_query($query) or die(mysql_error());
	$result=mysql_affected_rows();
	return $result;
}

//删除某条信息
function deletef($table,$condition1,$condition2){
	$query="delete from ".$table." where ".$condition1." = '".$condition2."';";
	mysql_query($query) or die(mysql_error());
	return 1;
}


?>